package tianrun.ziguan.api.calculate.config.service.template.analysis.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import tianrun.ziguan.api.calculate.config.dao.TUsageAnalysisModuleMapper;
import tianrun.ziguan.api.calculate.config.entity.TUsageAnalysisModule;
import tianrun.ziguan.api.calculate.config.service.template.analysis.ITUsageAnalysisModuleService;
import tianrun.ziguan.api.calculate.config.utils.CollectionUtil;

import java.util.Collections;
import java.util.List;
import java.util.Set;

/**
 * @author zhaoqi
 */
@Service
public class TUsageAnalysisModuleServiceImpl extends ServiceImpl<TUsageAnalysisModuleMapper, TUsageAnalysisModule> implements ITUsageAnalysisModuleService {

    @Override
    public List<TUsageAnalysisModule> listByTemplateIds(Set<Long> ids) {
        if (CollectionUtil.isEmpty(ids)) {
            return Collections.emptyList();
        }
        return list(Wrappers.<TUsageAnalysisModule>lambdaQuery().eq(TUsageAnalysisModule::getIsValid, true).in(TUsageAnalysisModule::getTemplateId, ids));
    }
}
